<%
## Tangent, an online sign-up sheet
## Copyright (C) 2008 Justin Ludwig and Adam Stuenkel
## 
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
## 
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
-%>

<% @page_title = "#{@activity} for #{@event}" %>

<div class="vevent">
	
<div class="h-container">
<h1 class="summary"><%=h @activity.name %> for <%= link_to_object @event, :class => 'related-to', :rel => 'parent' %></h1>
<span class="h1-tools">
  <%= link_to "Edit", edit_activity_path(@activity) if has_privilege_for_activity? @activity, :edit_activity %>
  <%= text_link_to_delete @activity if has_privilege_for_activity? @activity, :delete_activity %>
</span>
</div>

<% if @activity.activity_or_event_start_date -%>
<div class="pre-sidebar">
  <span class="dtstart" title="<%= @activity.activity_or_event_start_date.to_s :rfc3339 %>"><%= activity_starttime @activity %></span>
  <% if @activity.activity_or_event_end_date -%>
  -
  <span class="dtend" title="<%= @activity.activity_or_event_end_date.to_s :rfc3339 %>"><%= activity_endtime @activity %></span>
  <% end -%>
</div>
<% end -%>

<div class="sidebar">
  <h5><%= logged_in? ? 'My Status' : 'Sign Up' %></h5>
  <div class="content">
  <% if logged_in? -%>
    <div>
      <%= !@participant ? 'Not signed-up' : @participant.state.capitalize %>
    </div>
    <div class="buttons">
      <%= styled_button_to (!@participant || @participant.withdrawn? ? 'Sign Up' : 'Confirm'), confirm_activity_participants_path(@activity), :style => "width:8em;" if (@activity.available? && !(@participant && @participant.confirmed?)) %>
      <%= styled_button_to 'Withdraw', withdraw_activity_participants_path(@activity), :style => "width:8em;" unless (!@participant || @participant.withdrawn?) %>
    </div>

  <% else -%>
    <% form_tag sign_up_activity_participants_path(@activity) do -%>
    
    <label for="email">Email</label> <%= text_field_tag "email", params[:email], :class=> "medium" %>
    
    <div class="buttons">
      <%= styled_submit_tag "Sign Up", :style => "width:8em;" %>
    </div>
    
    <% end -%>
  <% end -%>
  </div>
</div>

<div class="metadata post-sidebar">
<% unless @activity.tag_list.blank? -%>
<div>
  Tagged as <%= list_tags @activity %>
</div>
<% end -%>
<% unless @activity.criteria.blank? -%>
<div>
  Criteria: <%= list_criteria @activity %>
</div>
<% end -%>
<div>
<% if @activity.unlimited? -%>
  Unlimited openings
<% else -%>
  <%= @activity.openings %> opening<%= @activity.openings > 1 ? 's' : '' %>, <%= @activity.available %> available
<% end -%>
</div>
</div>

<h4 class="under-sidebar">Details</h4>
<div class="description content">
<%= sanitize @activity.details %>
</div>

<% if has_privilege_for_activity? @activity, :view_participants %>
<table class="tbl">
<caption>Participants</caption>
<thead>
  <tr>
    <th><%= link_to_order_by "Name", "display_name" %></th>
    <th><%= link_to_order_by "Status", "state" %></th>
  </tr>
</thead>
<tbody>
<% for participant in @participants %>
  <tr class="attendee <%= cycle("", "alt") -%>">
    <td class="vcard"><%= link_to_object participant.person, :class => 'fn n url' %></td>
    <td class="partstat"><span title="<%= partstat participant %>"><%=h participant.state.capitalize %></span></td>
  </tr>
<% end %>
</table>
<%= links_to_page @participants %>
<% end %>

<div class="timestamp">
<div>
  Created on <span class="created" title="<%= @activity.created_at.to_s :rfc3339 %>"><%= @activity.created_at.to_s :full %></span>
</div>
<div>
  Last modified on <span class="last-modified" title="<%= @activity.updated_at.to_s :rfc3339 %>"><%= @activity.updated_at.to_s :full %></span>
</div>
</div>

</div>

